package com.sh.ssao.lottery.config.schedule;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 简单现场任务
 */
@Component
@EnableScheduling  // 1.开始定时任务
@EnableAsync       // 2.开启多线程
@Slf4j
public class MultithreadScheduliTask {

    //每日计算最新菜单价格（每天晚上10点整理）
    @Async
//    @Scheduled(fixedDelay = 1000*60*1)  //间隔1秒
    @Scheduled(cron = "0 0 22 * * ?")
    public void first() throws InterruptedException {
        System.out.println("***********************菜单价格计算开始 : " + Thread.currentThread().getName());

        System.out.println();
    }

    //发送当天邮件（每天早上八点发送）
//    @Async
//    @Scheduled(cron = "0 0 8 * * ? ")
//    public void second() {
//        System.out.println("***********************每日邮件发送,线程 : " + Thread.currentThread().getName());
//        emailInfoService.processBatchToEmail();
//    }

   /* @Async
    @Scheduled(cron = "0 0 1 1 * ?")
    public void cron() {
        mapper.selectByMap(new HashMap<>());
        System.out.println("第每月一日凌晨两点执行 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName());
        System.out.println();
    }*/
}
